/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package coms.json.action;

import Util.Constant;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.Result;
import coms.delegates.ConferenceDelegate;
import coms.dto.Conference;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Pk
 */
public class conferenceSelection extends coms.action.ComsActionSupport {

    private String conferenceId;

    public String getConferenceId() {
        return conferenceId;
    }

    public void setConferenceId(String conferenceId) {
        this.conferenceId = conferenceId;
    }
    HashMap<String, String> jsonData;

    public HashMap<String, String> getJsonData() {
        return jsonData;
    }

    public void setJsonData(HashMap<String, String> jsonData) {
        this.jsonData = jsonData;
    }

    public String conferenceDetail() {
        try {
            
            jsonData = new HashMap<String, String>();
            ConferenceDelegate comdel = new ConferenceDelegate();
            Conference search = new Conference();

            System.out.println("Conference Id" + conferenceId);
            int id = Integer.parseInt(conferenceId);
            search = comdel.getById(id);
            SimpleDateFormat sdf=new SimpleDateFormat(Constant.DATE_FORMAT);            
            System.out.println("Conference Found");
            System.out.println(search.getId());
            System.out.println(search.getName());
            jsonData.put("id", conferenceId + "");
            jsonData.put("name", search.getName());
            jsonData.put("detail", search.getDetail());
            jsonData.put("location", search.getLocation().toString());
            jsonData.put("cost", search.getCost() + "");
            jsonData.put("conferenceStartDate", sdf.format(search.getConferenceStartDate()) + "");
            jsonData.put("conferenceEndDate", sdf.format(search.getConferenceEndDate()) + "");
            
        } catch (Exception ex) {
            Logger.getLogger(conferenceSelection.class.getName()).log(Level.SEVERE, null, ex);
        }
        return SUCCESS;
    }

    public String getJSON() {
        return conferenceDetail();
    }
}
